<?php

namespace App\Model;

use Illuminate\Database\Eloquent\Model;

class OrderProduct extends Model
{
    //
    protected $table = 'order_products';

    protected $fillable = [
        'order_id', 'product_id', 'num', 'information', 'total_amount', 'status', 'date', 'serve_num', 'return_num', 'price'
    ];

    public function scopeOrderId($query, $order_id) {
        if(!empty($order_id)) {
            return $query->where('order_id', $order_id);
        }
        return $query;
    }

    public function scopeProductId($query, $product_id) {
        if(!empty($product_id)) {
            return $query->where('product_id', $product_id);
        }
        return $query;
    }
}
